<?php

declare(strict_types=1);

namespace App\Request\Init;

use App\Request\BaseCommonRequest;
use Hyperf\Context\Context;
use Hyperf\Validation\Request\FormRequest;

class CheckVersionRequest extends BaseCommonRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'package' => 'required',
            'from' => 'required|in:1,2',
            'version_code' => 'required',
            'channel' => 'required',
            'so_patch_failed2force_upgrade' => 'required|in:0,1',
        ];
    }


    /**
     * 获取已定义验证规则的错误消息
     */
    public function messages(): array
    {
        $language = Context::get('language', 'en');
        if ($language == 'zh-cn') {
            return [
                'package.required' => '包名必填',
                'from.required' => '系统类型必填',
                'from.in' => '系统类型只能是1，2',
                'version_code.required' => '版本号必填',
                'channel.required' => '渠道必填',
                'so_patch_failed2force_upgrade.required' => '包类型必填',
                'so_patch_failed2force_upgrade.in' => '包类型的值只能是0，1',
            ];
        } elseif ($language == 'zh-hk') {
            return [
                'package.required' => '包名必填',
                'from.required' => '系統類型必填',
                'from.in' => '系統類型只能是1，2',
                'version_code.required' => '版本號必填',
                'channel.required' => '渠道必填',
                'so_patch_failed2force_upgrade.required' => '包類型必填',
                'so_patch_failed2force_upgrade.in' => '包類型的值只能是0，1',
            ];
        } else {
            return [
                'package.required' => 'Package name is required',
                'from.required' => 'System type is required',
                'from.in' => 'System type only can be 1,2',
                'version_code.required' => 'Version code is required',
                'channel.required' => 'Channel is required',
                'so_patch_failed2force_upgrade.required' => 'Package type is required',
                'so_patch_failed2force_upgrade.in' => 'Package type only can be 0,1',
            ];
        }

    }

}